From: Jasper St. Pierre Date: Thu, 25 Apr 2013 20:24:14 +0000 (-0400) Subject: network: Deduplicate some similar code X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~4267 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=37dce7d4c37c490200ba168ca45bb4f9b4ed35dd;p=gnome-shell.git network: Deduplicate some similar code https://bugzilla.gnome.org/show_bug.cgi?id=698918 --- diff --git a/js/ui/status/network.js b/js/ui/status/network.js index 3f086b39f..cb5245817 100644 --- a/js/ui/status/network.js +++ b/js/ui/status/network.js @@ -2092,25 +2092,7 @@ const NMApplet = new Lang.Class({ return false; }, - _readConnections: function() { - let connections = this._settings.list_connections(); - for (let i = 0; i < connections.length; i++) { - let connection = connections[i]; - if (this._ignoreConnection(connection)) - continue; - if (connection._updatedId) { - // connection was already seen (for example because NetworkManager was restarted) - continue; - } - connection._removedId = connection.connect('removed', Lang.bind(this, this._connectionRemoved)); - connection._updatedId = connection.connect('updated', Lang.bind(this, this._updateConnection)); - - this._updateConnection(connection); - this._connections.push(connection); - } - }, - - _newConnection: function(settings, connection) { + _addConnection: function(connection) { if (this._ignoreConnection(connection)) return; if (connection._updatedId) { @@ -2123,7 +2105,15 @@ const NMApplet = new Lang.Class({ this._updateConnection(connection); this._connections.push(connection); + }, + _readConnections: function() { + let connections = this._settings.list_connections(); + connections.forEach(Lang.bind(this, this._addConnection)); + }, + + _newConnection: function(settings, connection) { + this._addConnection(connection); this._updateIcon(); },